﻿#pragma once

#include "Ability/EditorAbilityModel.h"
#include "EditorSceneOutlineAbilityModel.m.h"

class RScene;
class RSceneNode;
class REditorPageModel;

RCLASS(ExtraHeader= ["Scene/Scene.h","Scene/SceneNode.h","Pages/EditorPageModel.h"])
class REditorSceneOutlineAbilityModel : public REditorAbilityModel
{

    ROBJECT

public:
    virtual CString GetName() const { return U"场景节点"; }
    virtual void FirstTimeInitializeObject() override;

    RFUNCTION()
    void OnFocusedPageChanged(TSharedObjectPtr<REditorPageModel> InPage);


    //get current editing scene
    //if no scene is editing, return nullptr
    TSharedObjectPtr<RScene> GetScene() const;
    
    RFIELD()
    TSharedObjectPtr<RScene> Scene;

    //展开的节点/场景
    RFIELD()
    TVector<TSharedObjectPtr<RObject>> ExpandedNodes;

    bool IsNodeExpanded(TSharedObjectPtr<RObject> Node) const;

    TDelegate<void> OnSceneChanged;

    void FocusNode(TSharedObjectPtr<RObject> Node);
    TSharedObjectPtr<RObject> GetFocusedNode() const { return FocusedNode; } 
    
protected:

    TSharedObjectPtr<RObject> FocusedNode;

};